home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / Translation.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  12.7 KB  |  349 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        Translation.h
  3.  
  4.      Contains:    Translation Manager (Macintosh Easy Open) Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1991-1999 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __TRANSLATION__
  18. #define __TRANSLATION__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __FILES__
  25.     #include <Files.h>
  26. #endif
  27.  
  28. #ifndef __COMPONENTS__
  29.     #include <Components.h>
  30. #endif
  31.  
  32. #ifndef __TRANSLATIONEXTENSIONS__
  33.     #include <TranslationExtensions.h>
  34. #endif
  35.  
  36.  
  37.  
  38.  
  39. #if PRAGMA_ONCE
  40. #pragma once
  41. #endif
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47. #if PRAGMA_IMPORT
  48. #pragma import on
  49. #endif
  50.  
  51. #if PRAGMA_STRUCT_ALIGN
  52.     #pragma options align=mac68k
  53. #elif PRAGMA_STRUCT_PACKPUSH
  54.     #pragma pack(push, 2)
  55. #elif PRAGMA_STRUCT_PACK
  56.     #pragma pack(2)
  57. #endif
  58.  
  59. /* enumerated types on how a document can be opened*/
  60. typedef short                             DocOpenMethod;
  61. enum {
  62.     domCannot                    = 0,
  63.     domNative                    = 1,
  64.     domTranslateFirst            = 2,
  65.     domWildcard                    = 3
  66. };
  67.  
  68. /* 0L terminated array of OSTypes, or FileTypes*/
  69. typedef OSType                             TypesBlock[64];
  70. typedef OSType *                        TypesBlockPtr;
  71. /* Progress dialog resource ID*/
  72. enum {
  73.     kTranslationScrapProgressDialogID = -16555
  74. };
  75.  
  76. /* block of data that describes how to translate*/
  77.  
  78. struct FileTranslationSpec {
  79.     OSType                             componentSignature;
  80.     const void *                    translationSystemInfo;
  81.     FileTypeSpec                     src;
  82.     FileTypeSpec                     dst;
  83. };
  84. typedef struct FileTranslationSpec        FileTranslationSpec;
  85. typedef FileTranslationSpec *            FileTranslationSpecArrayPtr;
  86. typedef FileTranslationSpecArrayPtr *    FileTranslationSpecArrayHandle;
  87.  
  88. /*****************************************************************************************
  89. *   GetFileTypesThatAppCanNativelyOpen
  90. *  This routine returns a list of all FileTypes that an application can open by itself
  91. *  Enter:    appVRefNumHint        volume where application resides (can be wrong, and if is, will be used as a starting point)
  92. *             appSignature        signature (creator) of application
  93. *             nativeTypes            pointer to a buffer to be filled with up to 64 FileTypes
  94. *  Exit:    nativeTypes            zero terminated array of FileTypes that can be opened by app
  95. */
  96. EXTERN_API( OSErr )
  97. GetFileTypesThatAppCanNativelyOpen (short                 appVRefNumHint,
  98.                                  OSType                 appSignature,
  99.                                  FileType *                nativeTypes)                        TWOWORDINLINE(0x701C, 0xABFC);
  100.  
  101. /*****************************************************************************************
  102. *  ExtendFileTypeList
  103. *  This routine makes a new list of file types that can be translated into a type in the given list
  104. *  Used by StandardFile
  105. *  Enter:    originalTypeList        pointer to list of file types that can be opened
  106. *             numberOriginalTypes        number of file types in orgTypeList
  107. *              extendedTypeList        pointer to a buffer to be filled with file types
  108. *             numberExtendedTypes        max number of file types that can be put in extendedTypeList
  109. *  Exit:    extendedTypeList        buffer filled in with file types that can be translated
  110. *             numberExtendedTypes        number of file types put in extendedTypeList
  111. */
  112. EXTERN_API( OSErr )
  113. ExtendFileTypeList                (const FileType *        originalTypeList,
  114.                                  short                     numberOriginalTypes,
  115.                                  FileType *                extendedTypeList,
  116.                                  short *                numberExtendedTypes)                TWOWORDINLINE(0x7009, 0xABFC);
  117.  
  118.  
  119. /*****************************************************************************************
  120. *  This routine checks if a file can be opened by a particular application.
  121. *  If so, it returns if it needs to be translated first, and if so then how.
  122. *  The FileTypes that the app can open are specified by nativelyOpenableTypes,
  123. *  or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  124. *  Enter:    targetDocument        document to check if it can be opened
  125. *             appVRefNumHint        vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  126. *             appSignature        signature (creator) of application to open doc
  127. *             nativeTypes            zero terminated list of FileTypes app can open natively, or NULL to use default list
  128. *             onlyNative            whether to consider if document can be translated before opening
  129. *             howToOpen            pointer to buffer in which to put how the document can be opened
  130. *             howToTranslate        pointer to buffer in which to put a FileTranslationSpec record
  131. *  Exit:    howToOpen            whether file needs to be translated to be read
  132. *             howToTranslate        if file can be translated, buffer filled in with how to translate
  133. *             returns                noErr, noPrefAppErr
  134. */
  135. EXTERN_API( OSErr )
  136. CanDocBeOpened                    (const FSSpec *            targetDocument,
  137.                                  short                     appVRefNumHint,
  138.                                  OSType                 appSignature,
  139.                                  const FileType *        nativeTypes,
  140.                                  Boolean                 onlyNative,
  141.                                  DocOpenMethod *        howToOpen,
  142.                                  FileTranslationSpec *    howToTranslate)                        TWOWORDINLINE(0x701E, 0xABFC);
  143.  
  144.  
  145. /*****************************************************************************************
  146. *  GetFileTranslationPaths
  147. *  This routine returns a list of all ways a translation can occure to or from a FileType.
  148. *  The app is checked to exist.  The hint for each app is the VRefNum and DTRefNum
  149. *  Enter:    srcDoc            source file or NULL for all matches
  150. *             dstDoc            destination FileType or 0 for all matches
  151. *             maxResultCount
  152. *             resultBuffer
  153. *  Exit:    number of paths
  154. */
  155. EXTERN_API( short )
  156. GetFileTranslationPaths            (FSSpec *                srcDocument,
  157.                                  FileType                 dstDocType,
  158.                                  unsigned short         maxResultCount,
  159.                                  FileTranslationSpecArrayPtr  resultBuffer)                    TWOWORDINLINE(0x7038, 0xABFC);
  160.  
  161. /*****************************************************************************************
  162. *  GetPathFromTranslationDialog
  163. *  This routine, with a given document, application, and a passed typelist will display the
  164. *  Macintosh Easy Open translation dialog allowing the user to make a choice.  The choice
  165. *  made will be written as a preference (so the next call to CanDocBeOpened() will work).
  166. *  The routine returns the translation path information.
  167. *  Enter:    theDocument            FSSpec to document to open
  168. *             theApplication        FSSpec to application to open document
  169. *             typeList            Nil terminated list of FileType's (e.g. SFTypeList-like) of types
  170. *                                 you would like the documented translated to.  Order most perferred
  171. *                                 to least.
  172. *  Exit:    howToOpen            Translation method needed to open document
  173. *             howToTranslate        Translation specification
  174. *             returns                Any errors that might occur.
  175. */
  176. EXTERN_API( OSErr )
  177. GetPathFromTranslationDialog    (const FSSpec *            theDocument,
  178.                                  const FSSpec *            theApplication,
  179.                                  TypesBlockPtr             typeList,
  180.                                  DocOpenMethod *        howToOpen,
  181.                                  FileTranslationSpec *    howToTranslate)                        TWOWORDINLINE(0x7037, 0xABFC);
  182.  
  183.  
  184. /*****************************************************************************************
  185. *   TranslateFile
  186. *  This routine reads a file of one format and writes it to another file in another format. 
  187. *  The information on how to translated is generated by the routine CanDocBeOpened.
  188. *  TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.  
  189. *  The destination file must not exist.  It is created by this routine.  
  190. *  Enter:    sourceDocument            input file to translate
  191. *             destinationDocument        output file of translation
  192. *             howToTranslate            pointer to info on how to translate
  193. *  Exit:    returns                    noErr, badTranslationSpecErr 
  194. */
  195. EXTERN_API( OSErr )
  196. TranslateFile                    (const FSSpec *            sourceDocument,
  197.                                  const FSSpec *            destinationDocument,
  198.                                  const FileTranslationSpec * howToTranslate)                TWOWORDINLINE(0x700C, 0xABFC);
  199.  
  200. /*****************************************************************************************
  201. *   GetDocumentKindString
  202. *  This routine returns the string the Finder should show for the "kind" of a document
  203. *  in the GetInfo window and in the kind column of a list view.  
  204. *  Enter:    docVRefNum        The volume containing the document
  205. *             docType            The catInfo.fdType of the document
  206. *             docCreator        The catInfo.fdCreator of the document
  207. *             kindString        pointer to where to return the string
  208. *  Exit:    kindString        pascal string.  Ex: "\pSurfCalc spreadsheet"
  209. *             returns            noErr, or afpItemNoFound if kind could not be determined
  210. */
  211. EXTERN_API( OSErr )
  212. GetDocumentKindString            (short                     docVRefNum,
  213.                                  OSType                 docType,
  214.                                  OSType                 docCreator,
  215.                                  Str63                     kindString)                            TWOWORDINLINE(0x7016, 0xABFC);
  216.  
  217. /*****************************************************************************************
  218. *  GetTranslationExtensionName
  219. *  This routine returns the translation system name from a specified TranslationSpec
  220. *  Enter:    translationMethod    The translation path to get the translation name from
  221. *  Exit:    extensionName        The name of the translation system
  222. *             returns                Any errors that might occur
  223. */
  224. EXTERN_API( OSErr )
  225. GetTranslationExtensionName        (const FileTranslationSpec * translationMethod,
  226.                                  Str31                     extensionName)                        TWOWORDINLINE(0x7036, 0xABFC);
  227.  
  228.  
  229. /*****************************************************************************************
  230. *  GetScrapDataProcPtr
  231. *  This is a prototype for the function you must supply to TranslateScrap. It is called to 
  232. *  get the data to be translated.  The first call TranslateScrap will make to this is to
  233. *  ask for the 'fmts' data.  That is a special.   You should resize and fill in the handle
  234. *  with a list all the formats that you have available to be translated, and the length of each.
  235. *  (See I.M. VI 4-23 for details of 'fmts').  It will then be called again asking for one of  
  236. *  the formats that 'fmts' list said was available.
  237. *  Enter:    requestedFormat            Format of data that TranslateScrap needs.
  238. *             dataH                    Handle in which to put the requested data
  239. *             srcDataGetterRefCon        Extra parameter for you passed to TranslateScrap
  240. *             
  241. *  Exit:    dataH                    Handle is resized and filled with data in requested format
  242. */
  243. typedef CALLBACK_API( OSErr , GetScrapDataProcPtr )(ScrapType requestedFormat, Handle dataH, void *srcDataGetterRefCon);
  244. typedef STACK_UPP_TYPE(GetScrapDataProcPtr)                     GetScrapDataUPP;
  245. #if OPAQUE_UPP_TYPES
  246.     EXTERN_API(GetScrapDataUPP)
  247.     NewGetScrapDataUPP               (GetScrapDataProcPtr        userRoutine);
  248.  
  249.     EXTERN_API(void)
  250.     DisposeGetScrapDataUPP           (GetScrapDataUPP            userUPP);
  251.  
  252.     EXTERN_API(OSErr)
  253.     InvokeGetScrapDataUPP           (ScrapType                requestedFormat,
  254.                                     Handle                    dataH,
  255.                                     void *                    srcDataGetterRefCon,
  256.                                     GetScrapDataUPP            userUPP);
  257.  
  258. #else
  259.     enum { uppGetScrapDataProcInfo = 0x00000FE0 };                     /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes) */
  260.     #define NewGetScrapDataUPP(userRoutine)                         (GetScrapDataUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetScrapDataProcInfo, GetCurrentArchitecture())
  261.     #define DisposeGetScrapDataUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  262.     #define InvokeGetScrapDataUPP(requestedFormat, dataH, srcDataGetterRefCon, userUPP)  (OSErr)CALL_THREE_PARAMETER_UPP((userUPP), uppGetScrapDataProcInfo, (requestedFormat), (dataH), (srcDataGetterRefCon))
  263. #endif
  264. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  265. #define NewGetScrapDataProc(userRoutine)                         NewGetScrapDataUPP(userRoutine)
  266. #define CallGetScrapDataProc(userRoutine, requestedFormat, dataH, srcDataGetterRefCon) InvokeGetScrapDataUPP(requestedFormat, dataH, srcDataGetterRefCon, userRoutine)
  267.  
  268. typedef GetScrapDataUPP                 GetScrapData;
  269. /*****************************************************************************************
  270. *  TranslateScrap
  271. *  This routine resizes the destination handle and fills it with data of the requested format.
  272. *  The data is generated by translated one or more source formats of data supplied by
  273. *  the procedure srcDataGetter.  
  274. *  This routine is automatically called by GetScrap and ReadEdition.  You only need to call
  275. *  this if you need to translated scrap style data, but are not using the ScrapMgr or EditionMgr.
  276. *  Enter:    sourceDataGetter            Pointer to routine that can get src data
  277. *             sourceDataGetterRefCon        Extra parameter for dataGetter
  278. *             destinationFormat            Format of data desired
  279. *             destinationData                Handle in which to store translated data
  280. *             
  281. *  Exit:    dstData                        Handle is resized and filled with data in requested format
  282. */
  283. EXTERN_API( OSErr )
  284. TranslateScrap                    (GetScrapDataUPP         sourceDataGetter,
  285.                                  void *                    sourceDataGetterRefCon,
  286.                                  ScrapType                 destinationFormat,
  287.                                  Handle                 destinationData,
  288.                                  short                     progressDialogID)                    TWOWORDINLINE(0x700E, 0xABFC);
  289.  
  290.  
  291.  
  292.  
  293. #if PRAGMA_STRUCT_ALIGN
  294.     #pragma options align=reset
  295. #elif PRAGMA_STRUCT_PACKPUSH
  296.     #pragma pack(pop)
  297. #elif PRAGMA_STRUCT_PACK
  298.     #pragma pack()
  299. #endif
  300.  
  301. #ifdef PRAGMA_IMPORT_OFF
  302. #pragma import off
  303. #elif PRAGMA_IMPORT
  304. #pragma import reset
  305. #endif
  306.  
  307. #ifdef __cplusplus
  308. }
  309. #endif
  310.  
  311. #endif /* __TRANSLATION__ */
  312.  
  313.